<html>
<head>
</head>
<body>
<div class="clear" id="iframe">
</div>

<script src="http://wiki.wikignpi.googlecode.com/hg/gadgets/jquery.min.js" type="text/javascript"></script>
<script src="http://wikignpi.googlecode.com/svn/wiki/gadgets/jquery.min.js" type="text/javascript"></script>
<script src="http://wiki.wikignpi.googlecode.com/hg/gadgets/jquery.ba-postmessage.min.js" type="text/javascript"></script>
<script src="http://wikignpi.googlecode.com/svn/wiki/gadgets/jquery.ba-postmessage.min.js" type="text/javascript"></script>
<script type="text/javascript">

// Get userprefs
// var prefs = new gadgets.Prefs();

var gnpi_projectname = "wikignpi"; //prefs.getString("projectname");
var gnpi_subversion = "hg"; //prefs.getString("subversion");
var gnpi_wikiname = "News"; //prefs.getString("wikiname");
var gnpi_autoresize = true; //prefs.getBool("autoresize");
var gnpi_disableWarnings = true; //prefs.getBool("disableWarnings");
var gnpi_wikiBaseURL = "http://code.google.com/p/wikignpi/wiki/"; //prefs.getString("wikiBaseURL");
var gnpi_openURLSInNewWindow = true; //prefs.getBool("openURLSInNewWindow");
var gnpi_showLabels = false; //prefs.getBool("showLabels");
var gnpi_showSummary = false; //prefs.getBool("showSummary");

var gnpi_url="", gnpi_baselocation="http://";
if(gnpi_subversion.indexOf("hg")>=0) {
  gnpi_baselocation += "wiki."+gnpi_projectname+".googlecode.com";
  gnpi_url+= gnpi_baselocation + "/hg/gadgets/";
} else { /* gnpi_subversion.indexOf("svn")>=0 */
  gnpi_baselocation += gnpi_projectname+".googlecode.com";
  gnpi_url+=gnpi_baselocation+"/svn/wiki/gadgets/";
}
gnpi_url+="wikigateway.html?";

gnpi_url += '_gnpi_projectname="' + gnpi_projectname + '"'; gnpi_url+="&";
gnpi_url += '_gnpi_subversion="' + gnpi_subversion  + '"'; gnpi_url+="&";
gnpi_url += '_gnpi_auto_resize=' + gnpi_autoresize ; gnpi_url+="&";
gnpi_url += '_gnpi_disableWarnings=' + gnpi_disableWarnings ; gnpi_url+="&";
gnpi_url += '_gnpi_baseurl="' + gnpi_wikiBaseURL  + '"'; gnpi_url+="&";
gnpi_url += '_gnpi_openURLSInNewWindow=' + gnpi_openURLSInNewWindow; gnpi_url+="&";
gnpi_url += '_gnpi_wikiname="' + gnpi_wikiname + '"'; gnpi_url+="&";
gnpi_url += '_gnpi_showLabels=' + gnpi_showLabels; gnpi_url+="&";
gnpi_url += '_gnpi_showSummary=' + gnpi_showSummary;

$(function(){

  // Keep track of the iframe height.
  var if_height,

    // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
    // passed via query string or hard coded into the child page, it depends on your needs).
    src = gnpi_url + '#' + encodeURIComponent( document.location.href ),

    // Append the Iframe into the DOM.
    iframe = $( '<iframe src=' + "'" + src + "'" + ' width="100%" height="100%" scrolling="no" frameborder="0"><\/iframe>' )
      .appendTo( '#iframe' );

  // Setup a callback to handle the dispatched MessageEvent event. In cases where
  // window.postMessage is supported, the passed event will have .data, .origin and
  // .source properties. Otherwise, this will only have the .data property.
  $.receiveMessage(function(e){

    // Get the height from the passsed data.
    var h = Number( e.data.replace( /.*if_height=(\d+)(?:&|$)/, '$1' ) );

    if ( !isNaN( h ) && h > 0 && h !== if_height ) {
      // Height has changed, update the iframe.
      iframe.height( if_height = h );
      //if(gnpi_autoresize) gadgets.window.adjustHeight();
    }

  // An optional origin URL (Ignored where window.postMessage is unsupported).
  }, gnpi_baselocation );

});

</script>
<noscript>Please turn on JavaScript, otherwise you can't use this gadget...</noscript>
</body>
</html>
